<?php

namespace app\api\validate;

use think\Validate;
use app\common\Error;

class Login extends Validate
{
    protected $rule = [
        'code'  => 'require',
        'token' => 'require',
        'user_name' => 'require',
        'avatar' => 'require',
        'link_id' => 'require',
        'video_id' => 'require',
        'video_detail_id' => 'require',
        'app_id' => 'require',
        'device_id' => 'require',
        'mobile_system' => 'require',
        'phone' => 'require|regex:1[3-9]{1}[0-9]{9}',
        'sms_code' => 'require',
    ];

    protected $message  =   [
        'code.require'    => Error::CODE_NOT_EXIXTS,
        'token.require'    => Error::TOKEN_NOT_EXIXTS,
        'user_name.require'    => Error::USER_NAME_NOT_EXIXTS,
        'avatar.require'    => Error::AVATAR_NOT_EXIXTS,
        'link_id.require' => Error::LINK_ID_NOT_EXIXTS,
        'video_id.require' => Error::VIDEO_ID_NOT_EXIXTS,
        'video_detail_id.require' => Error::VIDEO_DETAIL_ID_NOT_EXIXTS,
        'app_id.require' => Error::APP_ID_NOT_EXIXTS,
        'device_id.require' => Error::DEVICE_ID_NOT_EXIXTS,
        'mobile_system.require' => Error::MOBILE_SYSTEM_NOT_EXIXTS,
        'phone.require' => Error::MOBILE_IS_NOT_EMPTY,
        'phone.regex' => Error::MOBILE_IS_ERROR,
        'sms_code.require' => Error::SMS_CODE_IS_NOT_EMPTY,
    ];

    protected $scene = [
        'login'  =>  ['code', 'app_id'],
        'get_wechat_user_info' => ['token', 'user_name', 'avatar'],
        'get_wx_url' => ['link_id', 'video_id', 'video_detail_id', 'clickid'],
        'fast_app_login' => ['device_id', 'mobile_system'],
        'sms_login' => ['phone', 'sms_code'],
        'sms_send' => ['phone'],
    ];
}